<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:mcv="http://myfaces.apache.org/commons/validators">

<h:head></h:head>

<h:body>
	<ui:composition>
	    <p:dialog id="new_user_dialog" widgetVar="newUserDialog" header="Create new user account"
	    	draggable="false" resizable="false" modal="true" closable="false">
	    	<h:form id="new_user_form">				
        		<h:panelGrid id="newUserGrid" columns="2" style="margin-bottom:10px" cellpadding="5">
        			<p:outputLabel for="newUserName" value="Name:" />
					<p:inputText id="newUserName" value="#{userBean.user.name}" />
					
					<p:outputLabel for="newUserLogin" value="Login:"/>
					<p:inputText id="newUserLogin" value="#{userBean.user.login}" required="true"
						requiredMessage="Login is required" validator="#{userBean.validateLogin}"
						autocomplete="false">
					</p:inputText>
						
					<p:outputLabel for="newUserEmail" value="E-mail:" />
					<p:inputText id="newUserEmail" value="#{userBean.user.email}"
						validator="#{userBean.validateEmail}"
						autocomplete="false">
					</p:inputText>
					
					<p:outputLabel for="newUserIsAdmin" value="Admin:" />
        			<p:selectBooleanCheckbox id="newUserIsAdmin" value="#{userBean.admin}" >
        				<p:ajax update="lblNewUserURL, newUserURL" />
        			</p:selectBooleanCheckbox>	
        			
        			<p:outputLabel id="lblNewUserURL" for="newUserURL" value="JIRA Server URL:" />
					<p:inputText id="newUserURL" value="#{userBean.url}"
						required="#{!userBean.admin}" disabled="#{userBean.admin}"
						requiredMessage="URL is required.">
						<mcv:validateUrl />
					</p:inputText>
					
					<p:outputLabel for="newUserPwd1" value="Password:" />
        			<p:password id="newUserPwd1" value="#{userBean.user.password}"
        			 	match="newUserPwd2" required="true"
        				requiredMessage="Password is required!"
        				validator="#{userBean.validatePassword}"
        				autocomplete="false"/>	
        				
 					<p:outputLabel for="newUserPwd2" value="Password confirmation:" />
        			<p:password id="newUserPwd2" value="{userBean.user.password}" 
        				required="true" requiredMessage="Password must be confirmed!"
        				autocomplete="false"/>        			   			
				</h:panelGrid>
				
				<h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="5">
						<p:commandButton id="buttonSave" value="Save" actionListener="#{userBean.createUser}"
							update="newUserGrid, :user_form:usersTable, :user_form:growl"
							oncomplete="if (args &amp;&amp; !args.validationFailed) PF('newUserDialog').hide();"
							onstart="PF('statusDialogForAdding').show();" onsuccess="PF('statusDialogForAdding').hide();"
							icon="ui-icon-check" />
						<p:commandButton value="Cancel" actionListener="#{userBean.cancelHandle}"
							immediate="true" oncomplete="PF('newUserDialog').hide();"
							icon="ui-icon-close" update="@form">
						</p:commandButton>	
				</h:panelGrid>
			</h:form>
		</p:dialog>
		
		<p:dialog id="loadStatusForAdding" widgetVar="statusDialogForAdding" modal="true" draggable="false" closable="false" 
			resizable="false" showHeader="false"  style="background-color: transparent; box-shadow: none; border: none;"  >
				<p:graphicImage  value="/resources/img/loading.gif" />	
		</p:dialog>
		
		</ui:composition>
	</h:body>
</html>